package com.dsl.dslallinone.dto;

import com.dsl.dslallinone.common.config.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.List;

/**
 * DSL查询请求
 */
@Data
@Schema(description = "DSL查询请求参数")
public class DslQuery {
    @Schema(description = "时间配置", required = true, example = "{\"window\":{\"start\":\"2025-08-01\",\"end\":\"2025-08-31\"},\"granularity\":\"day\"}")
    @Valid
    private TimeConfig time;

    @Schema(description = "维度字段列表", example = "[\"building_id\", \"floor_id\"]")
    private List<String> dimensions;

    @Schema(description = "指标配置列表", required = true)
    @Valid
    private List<MetricConfig> metrics;

    @Schema(description = "过滤条件列表")
    @Valid
    private List<FilterConfig> filter;

    @Schema(description = "分组字段列表", example = "[\"building_id\"]")
    private List<String> groupBy;

    @Schema(description = "排序配置列表")
    @Valid
    private List<OrderConfig> orderBy;

    @Schema(description = "查询结果限制", minimum = "1", maximum = "10000", example = "1000")
    @Min(value = 1, message = "limit最小值为1")
    @Max(value = 10000, message = "limit最大值为10000")
    private Integer limit = 1000;

    @Schema(description = "后处理配置")
    @Valid
    private PostConfig post;

    @Schema(description = "数据源类型", allowableValues = {"auto", "fact", "realtime"}, example = "auto")
    private String source = "auto"; // auto, fact, realtime
}
